using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GamePanel : BasePanel<GamePanel>
{
    public CustomGUIButton btSetting;
    public CustomGUIButton btExit;
    public CustomGUILabel labScore;
    public CustomGUILabel labTime;
    public CustomGUITexture texHP;
    public CustomGUITexture texMaxHP;
    //记录该玩家的当前分数
    [HideInInspector]//在Inspector面板上隐藏
    public int nowScore = 0;
    [HideInInspector]
    public float nowTime = 0;
    int time;
    public float hpWidth = 500;
    // Start is called before the first frame update
    void Start()
    {
        btSetting.clickEvent += () =>
        {
            Time.timeScale = 0;//暂停时间
            SettingPanel.Instance.ShowMe();
        };
        btExit.clickEvent += () =>
        {
            Time.timeScale = 0;//暂停时间
            QuitPanel.Instance.ShowMe();
        };
        // AddScore(100);
    }
    public void AddScore(int score)
    {
        nowScore += score;
        labScore.content.text = nowScore.ToString();
    }
    public void UpadteHPPanel(float originalmaxHp, float hp, float extraMaxHp)
    {
        texMaxHP.guiPos.width = (originalmaxHp + extraMaxHp) / (float)originalmaxHp * hpWidth;

        texHP.guiPos.width = hp / (float)(originalmaxHp + extraMaxHp) * texMaxHP.guiPos.width;
    }

    // Update is called once per frame
    void Update()
    {
        nowTime += Time.deltaTime;
        time = (int)nowTime;
        labTime.content.text = "";
        if (time / 3600 > 0)
        {
            labTime.content.text += time / 3600 + "时";
        }
        if (time % 3600 / 60 > 0 || time / 3600 > 0)
        {
            labTime.content.text += time % 3600 / 60 + "分";
        }
        labTime.content.text += time % 60 + "秒";

    }
}
